<!DOCTYPE html>
<html>
<head><meta charset="utf-8" />
<title>auxstructuredoc</title><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>

<style type="text/css">
/* Overrides of notebook CSS for static HTML export */
body {
  overflow: visible;
  padding: 8px;
}
div#notebook {
  overflow: visible;
  border-top: none;
}@media print {
  div.cell {
    display: block;
    page-break-inside: avoid;
  } 
  div.output_wrapper { 
    display: block;
    page-break-inside: avoid; 
  }
  div.output { 
    display: block;
    page-break-inside: avoid; 
  }
}
</style>

<!-- Custom stylesheet, it must be in the parent directory as the html file -->
<link rel="stylesheet" type="text/css" media="all" href="../doc.css" />
<link rel="stylesheet" type="text/css" media="all" href="doc.css" />

<!-- Loading mathjax macro -->
<!-- Load mathjax -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS_HTML"></script>
    <!-- MathJax configuration -->
    <script type="text/x-mathjax-config">
    MathJax.Hub.Config({
        tex2jax: {
            inlineMath: [ ['$','$'], ["\\(","\\)"] ],
            displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
            processEscapes: true,
            processEnvironments: true
        },
        // Center justify equations in code and markdown cells. Elsewhere
        // we use CSS to left justify single line equations in code cells.
        displayAlign: 'center',
        "HTML-CSS": {
            styles: {'.MathJax_Display': {"margin": 0}},
            linebreaks: { automatic: true }
        }
    });
    </script>
    <!-- End of mathjax configuration --></head>
<body>
  <div tabindex="-1" id="notebook" class="border-box-sizing">
    <div class="container" id="notebook-container">

<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h1 id="Auxiliary-Mesh-Data-Structure">Auxiliary Mesh Data Structure<a class="anchor-link" href="#Auxiliary-Mesh-Data-Structure">&#182;</a></h1>
</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>We discuss ways to extract the combinatorial structure of a triangulation by using <code>elem</code> array only. Auxiliary data structure includes:</p>
<ul>
<li>2D: <code>edge, elem2edge, edge2elem, neighbor, bdEdge</code></li>
<li>3D: <code>face, elem2face, face2elem, neighbor, bdFace</code></li>
</ul>
<p>They are wrapped into a mesh structure <code>T</code> and generated by</p>

<pre><code>    T = auxstructure(elem);  % 2-D
    T = auxstructure3(elem); % 3-D</code></pre>

</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>The auxiliary data structure can be constructed by <em>sparse matrixlization</em> efficiently; see <a href="auxstructuredoc.pdf">Auxiliary Mesh Data Structure</a> for detailed explanation. In the following, we present two examples.</p>

</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="edge">edge<a class="anchor-link" href="#edge">&#182;</a></h2><p>We first complete the 2-D simplicial complex represented by <code>elem</code> by constructing 1-dimensional simplices, i.e., edges of the triangulation. We use <code>edge(1:NE,1:2)</code> to store indices of the starting and ending points of edges. The column is sorted in a way such that for the k-th edge, <code>edge(k,1)&lt;edge(k,2)</code>. The following code will generate an <code>edge</code> matrix.</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[3]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-matlab"><pre><span></span><span class="p">[</span><span class="n">node</span><span class="p">,</span><span class="n">elem</span><span class="p">]</span> <span class="p">=</span> <span class="n">squaremesh</span><span class="p">([</span><span class="mi">0</span> <span class="mi">1</span> <span class="mi">0</span> <span class="mi">1</span><span class="p">],</span><span class="mf">0.5</span><span class="p">);</span>
<span class="n">totalEdge</span> <span class="p">=</span> <span class="n">sort</span><span class="p">([</span><span class="n">elem</span><span class="p">(:,[</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">]);</span> <span class="n">elem</span><span class="p">(:,[</span><span class="mi">3</span><span class="p">,</span><span class="mi">1</span><span class="p">]);</span> <span class="n">elem</span><span class="p">(:,[</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">])],</span><span class="mi">2</span><span class="p">);</span>
<span class="p">[</span><span class="nb">i</span><span class="p">,</span><span class="nb">j</span><span class="p">,</span><span class="n">s</span><span class="p">]</span> <span class="p">=</span> <span class="nb">find</span><span class="p">(</span><span class="n">sparse</span><span class="p">(</span><span class="n">totalEdge</span><span class="p">(:,</span><span class="mi">2</span><span class="p">),</span><span class="n">totalEdge</span><span class="p">(:,</span><span class="mi">1</span><span class="p">),</span><span class="mi">1</span><span class="p">));</span>
<span class="n">edge</span> <span class="p">=</span> <span class="p">[</span><span class="nb">j</span><span class="p">,</span><span class="nb">i</span><span class="p">];</span> 
<span class="n">bdEdge</span> <span class="p">=</span> <span class="p">[</span><span class="nb">j</span><span class="p">(</span><span class="n">s</span><span class="o">==</span><span class="mi">1</span><span class="p">),</span><span class="nb">i</span><span class="p">(</span><span class="n">s</span><span class="o">==</span><span class="mi">1</span><span class="p">)];</span>
<span class="n">showmesh</span><span class="p">(</span><span class="n">node</span><span class="p">,</span><span class="n">elem</span><span class="p">);</span>
<span class="n">findedge</span><span class="p">(</span><span class="n">node</span><span class="p">,</span><span class="n">edge</span><span class="p">,</span><span class="n">s</span><span class="o">==</span><span class="mi">1</span><span class="p">);</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt"></div>




<div class="output_png output_subarea ">
<img src="
B3RJTUUH4gkHFRQu7wrx4AAAACR0RVh0U29mdHdhcmUATUFUTEFCLCBUaGUgTWF0aFdvcmtzLCBJ
bmMuPFjdGAAAACJ0RVh0Q3JlYXRpb24gVGltZQAwNy1TZX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goXDhcHj+WcFVq39RzJY0YPe1
x27kXI0fsQDgLoKEohS5JbEZ+R0LAC4iSChWwVsSm5EaWABwC0GCC7K3pEAOX9qWTA2uf2LN6s7b
2YzUwAKAK3jZN1xjWVZzc7Nt20GjvNKsXmRelv0FbsnU4IC96fXUYJe10rll165dXMRWCQsARSJI
cJNt27Zt9/T0WJZlWZaIOHtTMjXkvO3RNM1oNFpXV8ffxUpiAaAYBAlTxbZty7Kcr95w/hDmU5y1
wgJAvggSAMAT+KQGAIAnECQAgCcQJACAJxAkAIAnECQAgCcQJACAJxAkAIAnECQAgCcQJACAJxAk
AIAnECQAgCcQJACAJxAkAIAnECQAgCcQJACAJxAkAIAnECQAgCcQJACAJxAkAIAnECQAgCcQJACA
JxAkAIAnECQAgCcQJACAJxAkAIAnECQAgCcQJACAJxAkAIAnECQAgCf8f+AVijuGsxoOAAAAAElF
TkSuQmCC
"
>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>The first line collects all edges from the set of triangles and sorts the column such that <code>totalEdge(k,1)&lt;totalEdge(k,2)</code>. The interior edges are repeated twice in <code>totalEdge</code>. We use the summation property of <code>sparse</code> command to merge the duplicated indices. The nonzero vector <code>s</code> takes value 1 (for boundary edges) or 2 (for interior edges). We then use <code>find</code> to return the nonzero indices which forms the <code>edge</code> set. We can also find the boundary edges using the subset of indices pair corresponding to the nonzero value 1. Note that we switch the order of <code>(i,j)</code> in line 3 to sort the edge set row-wise since the output of <code>find(sparse)</code> is sorted column-wise.</p>

</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>To construct <code>edge</code> matrix only, the above 3 line code can be further simplified to one line:
<code>edge = unique(sort([elem(:,[2,3]); elem(:,[3,1]); elem(:,[1,2])],2),'rows');</code>
The <code>unique</code> function provides more functionality which we shall explore more later. However, numerical tests show that the running time of <code>unique</code> is around 3 times of the combination <code>find(sparse)</code>.</p>

</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Node-Star">Node Star<a class="anchor-link" href="#Node-Star">&#182;</a></h2><p>The <code>elem</code> matrix, by the definition, is a link from triangles to vertices, i.e., <code>elem</code> is <code>elem2node</code>. The link from vertices to triangles, namely given a vertex, to find all triangles containing this vertex, is stored in the sparse matrix:</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[8]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-matlab"><pre><span></span><span class="n">NT</span> <span class="p">=</span> <span class="nb">size</span><span class="p">(</span><span class="n">elem</span><span class="p">,</span><span class="mi">1</span><span class="p">);</span> <span class="n">N</span> <span class="p">=</span> <span class="nb">size</span><span class="p">(</span><span class="n">node</span><span class="p">,</span><span class="mi">1</span><span class="p">);</span>
<span class="n">t2v</span> <span class="p">=</span> <span class="n">sparse</span><span class="p">([</span><span class="mi">1</span><span class="p">:</span><span class="n">NT</span><span class="p">,</span><span class="mi">1</span><span class="p">:</span><span class="n">NT</span><span class="p">,</span><span class="mi">1</span><span class="p">:</span><span class="n">NT</span><span class="p">],</span> <span class="n">elem</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">NT</span><span class="p">,</span> <span class="n">N</span><span class="p">);</span>
<span class="n">display</span><span class="p">(</span><span class="n">full</span><span class="p">(</span><span class="n">t2v</span><span class="p">));</span>
<span class="n">nodeStar</span> <span class="p">=</span> <span class="nb">find</span><span class="p">(</span><span class="n">t2v</span><span class="p">(:,</span><span class="mi">5</span><span class="p">));</span>
<span class="n">showmesh</span><span class="p">(</span><span class="n">node</span><span class="p">,</span><span class="n">elem</span><span class="p">);</span>
<span class="n">findelem</span><span class="p">(</span><span class="n">node</span><span class="p">,</span><span class="n">elem</span><span class="p">,</span><span class="n">nodeStar</span><span class="p">);</span>
<span class="n">findnode</span><span class="p">(</span><span class="n">node</span><span class="p">,</span><span class="mi">5</span><span class="p">);</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt"></div>


<div class="output_subarea output_stream output_stdout output_text">
<pre>     1     0     0     1     1     0     0     0     0
     0     1     0     0     1     1     0     0     0
     0     0     0     1     0     0     1     1     0
     0     0     0     0     1     0     0     1     1
     1     1     0     0     1     0     0     0     0
     0     1     1     0     0     1     0     0     0
     0     0     0     1     1     0     0     1     0
     0     0     0     0     1     1     0     0     1

</pre>
</div>
</div>

<div class="output_area">

<div class="prompt"></div>




<div class="output_png output_subarea ">
<img src="
B3RJTUUH4gkHFRcnvfsahwAAACR0RVh0U29mdHdhcmUATUFUTEFCLCBUaGUgTWF0aFdvcmtzLCBJ
bmMuPFjdGAAAACJ0RVh0Q3JlYXRpb24gVGltZQAwNy1TZXAtMjAxOCAxNDoyMzozOSqrg7MAAB0v
SURBVHic7d1/jBxl4cfxz9IC4UehQIDYAjeV2j80MRJBoUB3F2qwEH6J0YiNu2fif8QQCCGKSfcM
ICGgBeUfRbsXv/qHwSI/LCLgzVbh+GW1IBGBpgMIEYhtoYUa+uO+f8xwd93bvZv9Nc/zzPN+pX9c
926mj8fjvHdnnt0pTExMCAAA0w4yPQAAACSCBACwBEECAFiBIAEArECQAABWIEgAACsQJACAFQgS
AMAKBAkAYAWCBACwAkECAFiBIAEArECQAABWIEgAACsQJACAFQgSAMAKBAkAYAWCBACwAkECAFiB
IAEArECQAABWIEgAACsQJACAFQgSAMAKBAkAYAWCBACwAkECAFiBIAEArECQAABWmG96APkXhmGj
0TA9CgDGFIvFUqlkehQOKExMTJgeQ84VCoXStWeZHgXM2PH6e3//zQulkjgceatWkySOtGkQpIEr
FAq1N681PQoYsOP193731Z8FgUolrVljejQwYXhYkup1gpQK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PUCI4i
SHlDjTxHjeAugpQr1Mhz1AhOI0j5QY08R43gOoKUE9TIc9QIOUCQ8oAaeY4aIR8IkvOokeeoEXKD
ILmNGnmOGiFPCJLDqJHnqBFyhiC5ihp5jhohfwiSk6iR56gRcokguYcaeY4aIa8IkmOokeeoEXKM
ILmEGnmOGiHfCJIzqJHnqBFyjyC5gRp5jhrBBwTJAdTIc9QIniBItqNGnqNG8AdBsho18hw1glcI
kr2okeeoEXxDkCxFjTxHjeAhgmQjauQ5agQ/ESTrUCPPUSN4iyDZhRp5jhrBZwTJItTIc9QIniNI
tqBGnqNGAEGyAjXyHDUCRJBsQI08R42AGEEyjBp5jhoBkwiSSdTIc9QImI4gGUONPEeNgCYEyQxq
5DlqBMxEkAygRp6jRkBLBClr1Mhz1AhohyBlihp5jhoBsyBI2aFGnqNGwOwIUkaokeeoETAngpQF
auQ5agSkUZiYmDA9hpwrFAqSajXT44AhYagwVHDWycHyk0yPBWaEt49zpE2DIA1cGIaNRsP0KAAY
UywWS6WS6VE4gCABAKzANSQAgBUIEgDACgQJAGAFggQAsAJBAgBYgSABAKxAkAAAViBIAAArECQA
gBUIEgDACgQJAGAFggQAsAJBAgBYgSABAKxAkAAAViBIAAArECQAgBUIEgDACgQJAGAFggQAsAJB
AgBYgSABAKxAkAAAViBIAAArECQAgBUIEgDACgQJAGAFggQAsAJBAgBYgSABAKxAkAAAViBIAAAr
ECQAgBUIEgDACgQJAGAFggQAsAJBAgBYgSABAKxAkAAAViBIAAArECQAgBUIEgDACgQJAGAFggQA
sML/A8LpHitCO+rRAAAAAElFTkSuQmCC
"
>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>The NT x N matrix <code>t2v</code> is the incidence matrix between triangles and vertices. <code>t2v(t,i)=1</code> means the i-th node is a vertex of triangle t. If we look at <code>t2v</code> column-wise, the nonzero in the i-th column of <code>t2v(:,i)</code> will give all triangles containing the $i$-th node. Since sparse matrix is stored column-wise, the star of the $i$-th node can be efficiently found by <code>nodeStar = find(t2v(:,i))</code>.</p>

</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="elem2edge">elem2edge<a class="anchor-link" href="#elem2edge">&#182;</a></h2><p>We label three edges of a triangle such that the i-th edge is opposite to the i-th vertex. We define the matrix <code>elem2edge</code> as the map of local index of edges in each triangle to its global index. The following 3 line code will construct <code>elem2edge</code> using more output from <code>unique</code> function.</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[2]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-matlab"><pre><span></span><span class="p">[</span><span class="n">node</span><span class="p">,</span><span class="n">elem</span><span class="p">]</span> <span class="p">=</span> <span class="n">squaremesh</span><span class="p">([</span><span class="mi">0</span> <span class="mi">1</span> <span class="mi">0</span> <span class="mi">1</span><span class="p">],</span><span class="mf">0.5</span><span class="p">);</span>
<span class="n">totalEdge</span> <span class="p">=</span> <span class="n">sort</span><span class="p">([</span><span class="n">elem</span><span class="p">(:,[</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">]);</span> <span class="n">elem</span><span class="p">(:,[</span><span class="mi">3</span><span class="p">,</span><span class="mi">1</span><span class="p">]);</span> <span class="n">elem</span><span class="p">(:,[</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">])],</span><span class="mi">2</span><span class="p">);</span>
<span class="p">[</span><span class="n">edge</span><span class="p">,</span> <span class="n">i2</span><span class="p">,</span> <span class="nb">j</span><span class="p">]</span> <span class="p">=</span> <span class="n">unique</span><span class="p">(</span><span class="n">totalEdge</span><span class="p">,</span><span class="s">&#39;rows&#39;</span><span class="p">,</span><span class="s">&#39;legacy&#39;</span><span class="p">);</span>
<span class="n">NT</span> <span class="p">=</span> <span class="nb">size</span><span class="p">(</span><span class="n">elem</span><span class="p">,</span><span class="mi">1</span><span class="p">);</span>
<span class="n">elem2edge</span> <span class="p">=</span> <span class="nb">reshape</span><span class="p">(</span><span class="nb">j</span><span class="p">,</span><span class="n">NT</span><span class="p">,</span><span class="mi">3</span><span class="p">);</span>
</pre></div>

</div>
</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>Line 1 collects all edges element-wise. The size of <code>totalEdge</code> is thus 3NT x 2. By the construction, there is a natural index mapping from <code>totalEdge</code> to <code>elem</code>. In line 2, we apply <code>unique</code> function to obtain the edge matrix. The output index vectors <code>i2</code> and <code>j</code> contain the index mapping between <code>edge</code> and <code>totalEdge</code>. Here <code>i2</code> is a NE x 1 vector to index the last (2-nd in our case) occurrence of each unique value in <code>totalEdge</code> such that <code>edge = totalEdge(i2,:)</code>, while <code>j</code> is a 3NT x 1 vector such that <code>totalEdge = edge(j,:)</code>. (Try <code>help unique</code> in MATLAB to learn more examples. <code>legacy</code> is used since the version change of MATLAB.) Then using the natural index mapping from <code>totalEdge</code> to <code>elem</code>, we reshape the 3NT x 1 vector <code>j</code> to a NT x 3 matrix which is <code>elem2edge</code>.</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[3]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-matlab"><pre><span></span><span class="n">showmesh</span><span class="p">(</span><span class="n">node</span><span class="p">,</span><span class="n">elem</span><span class="p">);</span>
<span class="n">findelem</span><span class="p">(</span><span class="n">node</span><span class="p">,</span><span class="n">elem</span><span class="p">,</span><span class="mi">6</span><span class="p">);</span>
<span class="n">findedge</span><span class="p">(</span><span class="n">node</span><span class="p">,</span><span class="n">edge</span><span class="p">,</span><span class="n">elem2edge</span><span class="p">(</span><span class="mi">6</span><span class="p">,:));</span>
<span class="n">display</span><span class="p">(</span><span class="n">elem2edge</span><span class="p">);</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt"></div>


<div class="output_subarea output_stream output_stdout output_text">
<pre>
elem2edge =

     3     2     8
     6     5    11
    10     9    15
    13    12    16
     3     5     1
     6     7     4
    10    12     8
    13    14    11

</pre>
</div>
</div>

<div class="output_area">

<div class="prompt"></div>




<div class="output_png output_subarea ">
<img src="
B3RJTUUH4gkHFSMVzga48AAAACR0RVh0U29mdHdhcmUATUFUTEFCLCBUaGUgTWF0aFdvcmtzLCBJ
bmMuPFjdGAAAACJ0RVh0Q3JlYXRpb24gVGltZQAwNy1TZXAtMjAxOCAxNDozNToyMSVgTKwAABu+
SURBVHic7d17cFzVfcDx35p3HMyCeETGxpcE5LQmRMYJGalJdjVhGsLYGadJXZhkqtWkMU2YTKFO
6CNJte60mem05t1JcQdYdRogToaaWqXUnVh3myABsYxCbQhKjI8QlRJAYe0mJTzi7R9XyELWrlZ3
7+499/y+n7/k1d3LmTODvnPuPbs3VS6XBQCAuC2JewAAAIgQJACAJQgSAMAKBAkAYAWCBACwAkEC
AFiBIAEArECQAABWIEgAACsQJACAFQgSAMAKBAkAYAWCBACwAkECAFiBIAEArHBi3AOAs4wxvu+P
jY35vu95XiaTyeVycQ8KgL1SPKAP0TLG9PX1+b7v+76ItKRb27x1U6XJUTMsIp7nZbPZ7u7ubDYb
7zgB2IYgITK+7/f09BhjWtKtHe0bRGRDdvPMb6dKE6Nm3zNmbxAnz/N6e3tZMwGYQZAQDd/3u7q6
1mc3d7avb0kvr37wVGlicKR/v9mdy+V6e3ubM0IAliNIiEBQoy25O9u8dbW/a2ik3x8p0CQAATY1
oF7haiQiHe3rRaRQKIgITQJAkFCX0DUK0CQAMwgSwquzRoGZJq1atYo9DoBm3ENCeKlUKrcxHxSl
TsH9pEOHDtV/KgAJxQoJIQXX2dq8y+b97f4fP/Jv/3XX8a//3p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ALACQQIAWIEg
AQCsQJAAAFYgSAAAKxAkAIAVCBIAwAoECQBgBYIEALACQQIAWIEgAQCsQJAAAFYgSAAAKxAkAIAV
CBIAwAoECQBgBYIEALACQQIAWIEgAQCsQJAAAFYgSAAAKxAkAIAVCBIAwAoECQBgBYIEALACQQIA
WIEgAQCsQJAAAFYgSAAAKxAkAIAVCBIAwAoECQBgBYIEALACQQIAWIEgAQCsQJAAAFYgSAAAKxAk
AIAVCBIAwAoECQBgBYIEALACQQIAWIEgAQCsQJAAAFb4f2Csdm8Og8C9AAAAAElFTkSuQmCC
"
>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="edge2elem">edge2elem<a class="anchor-link" href="#edge2elem">&#182;</a></h2><p>We then define a NE x 4 matrix <code>edge2elem</code> such that <code>edge2elem(k,1)</code> and <code>edge2elem(k,2)</code> are two triangles sharing the k-th edge for an interior edge. If the k-th edge is on the boundary, then we set <code>edge2elem(k,1) = edge2elem(k,2)</code>. Furthermore, we shall record the local indices in <code>edge2elem(k,3:4)</code> such that <code>elem2edge(edge2elem(k,1),edge2elem(k,3))=k</code>. Similarly <code>edge2elem(k,4)</code> is the local index of k-th edge in <code>edge2elem(k,2)</code>.</p>
<p>To construct <code>edge2elem</code> matrix, we need to find out the index map from <code>edge</code> to <code>elem</code>. The following code is a continuation of the code constructing <code>elem2edge</code>.</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[7]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-matlab"><pre><span></span><span class="n">i1</span><span class="p">(</span><span class="nb">j</span><span class="p">(</span><span class="mi">3</span><span class="o">*</span><span class="n">NT</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">:</span><span class="mi">1</span><span class="p">))</span> <span class="p">=</span> <span class="mi">3</span><span class="o">*</span><span class="n">NT</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">:</span><span class="mi">1</span><span class="p">;</span> <span class="n">i1</span><span class="p">=</span><span class="n">i1</span><span class="o">&#39;</span><span class="p">;</span>
<span class="n">k1</span> <span class="p">=</span> <span class="nb">ceil</span><span class="p">(</span><span class="n">i1</span><span class="o">/</span><span class="n">NT</span><span class="p">);</span> <span class="n">t1</span> <span class="p">=</span> <span class="n">i1</span> <span class="o">-</span> <span class="n">NT</span><span class="o">*</span><span class="p">(</span><span class="n">k1</span><span class="o">-</span><span class="mi">1</span><span class="p">);</span>
<span class="n">k2</span> <span class="p">=</span> <span class="nb">ceil</span><span class="p">(</span><span class="n">i2</span><span class="o">/</span><span class="n">NT</span><span class="p">);</span> <span class="n">t2</span> <span class="p">=</span> <span class="n">i2</span> <span class="o">-</span> <span class="n">NT</span><span class="o">*</span><span class="p">(</span><span class="n">k2</span><span class="o">-</span><span class="mi">1</span><span class="p">);</span>
<span class="n">edge2elem</span> <span class="p">=</span> <span class="p">[</span><span class="n">t1</span><span class="p">,</span><span class="n">t2</span><span class="p">,</span><span class="n">k1</span><span class="p">,</span><span class="n">k2</span><span class="p">];</span>
</pre></div>

</div>
</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>The code in line 1 uses <code>j</code> to find the first occurrence of each unique edge in the <code>totalEdge</code>. In MATLAB, when assign values using an index vector with duplication, the value at the repeated index will be the last one assigned to this location. Obvious <code>j</code> contains duplication of edge indices. For example, <code>j(1)=j(2)=4</code> which means <code>totalEdge(1,:)=totalEdge(2,:)=edge(4,:)</code>. We reverse the order of <code>j</code> such that <code>i1(4)=1</code> which is the first occurrence.</p>
<p>Using the natural index mapping from <code>totalEdge</code> to <code>elem</code>, for an index <code>i</code> between <code>1:N</code>, the formula <code>k=ceil(i/NT)</code> computes the local index of i-th edge, and <code>t=i-NT*(k-1)</code> is the global index of the triangle which <code>totalEdge(i,:)</code> belongs to. The <code>edge2elem</code> is just composed by <code>t1,t2,k1</code> and <code>k2</code>.</p>

</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[9]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-matlab"><pre><span></span><span class="n">showmesh</span><span class="p">(</span><span class="n">node</span><span class="p">,</span><span class="n">elem</span><span class="p">);</span>
<span class="n">findelem</span><span class="p">(</span><span class="n">node</span><span class="p">,</span><span class="n">elem</span><span class="p">,</span><span class="n">edge2elem</span><span class="p">(</span><span class="mi">6</span><span class="p">,</span><span class="mi">1</span><span class="p">:</span><span class="mi">2</span><span class="p">));</span>
<span class="n">findedge</span><span class="p">(</span><span class="n">node</span><span class="p">,</span><span class="n">edge</span><span class="p">,</span><span class="mi">6</span><span class="p">);</span>
<span class="n">display</span><span class="p">(</span><span class="n">edge2elem</span><span class="p">);</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt"></div>


<div class="output_subarea output_stream output_stdout output_text">
<pre>
edge2elem =

     5     5     3     3
     1     1     2     2
     1     5     1     1
     6     6     3     3
     2     5     2     2
     2     6     1     1
     6     6     2     2
     1     7     3     3
     3     3     2     2
     3     7     1     1
     2     8     3     3
     4     7     2     2
     4     8     1     1
     8     8     2     2
     3     3     3     3
     4     4     3     3

</pre>
</div>
</div>

<div class="output_area">

<div class="prompt"></div>




<div class="output_png output_subarea ">
<img src="
B3RJTUUH4gkHFSAN9kdzZQAAACR0RVh0U29mdHdhcmUATUFUTEFCLCBUaGUgTWF0aFdvcmtzLCBJ
bmMuPFjdGAAAACJ0RVh0Q3JlYXRpb24gVGltZQAwNy1TZXAtMjAxOCAxNDozMjoxM32URvoAABg/
SURBVHic7d1vjF3nXeDx3zjOn5Jta+KEYifFVyVxd5WlOASKbHWZOzRSSXBQoi4RoSvNHbF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jTKnRjSGINWbGmVOjWgSQaoxNcqcGtEwglRXapQ5NaJ5
BKmW1ChzakQjCVL9qFHm1IimEqSaUaPMqRENJkh1okaZUyOaTZBqQ40yp0Y0niDVgxplTo3IgSDV
gBplTo3IhCClTo0yp0bkQ5CSpkaZUyOyIkjpUqPMqRG5EaREqVHm1IgMCVKK1ChzakSeBCk5apQ5
NSJbgpQWNcqcGpEzQUqIGmVOjcicIKVCjTKnRiBISVCjzKkRhCClQI0yp0ZQEqSKqVHm1AgWCFKV
1ChzagSLCVJl1ChzagRLCFI11ChzagSXEqQKqFHm1AiWJUjDpkaZUyNYiSANlRplTo1gFYI0PGqU
OTWC1QnSkKhR5tQI1iRIw6BGmVMjWI+Rubm5qsfQcCMjIxHRfnBv1QOhGsUTzxfHnmvtfXNr3w1V
j4VqdD96zCftegjSwHW73dnZ2apHAVRmdHS03W5XPYoaECQAkuAeEgBJECQAkiBIACRBkABIgiAB
kARBAiAJggRAEgQJgCQIEgBJECQAkiBIACRBkABIgiABkARBAiAJggRAEgQJgCQIEgBJECQAkiBI
ACRBkABIgiABkARBAiAJggRAEgQJgCQIEgBJECQAkiBIACRBkABIgiABkARBAiAJggRAEgQJgCQI
EgBJECQAkiBIACRBkABIgiABkARBAiAJggRAEgQJgCQIEgBJECQAkiBIACRBkABIwr8AkKBtcWvH
rbwAAAAASUVORK5CYII=
"
>
</div>

</div>

</div>
</div>

</div>
    </div>
  </div>
</body>

 


</html>
